home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / HILITEWD.AML < prev    next >
Text File  |  1996-07-17  |  2KB  |  69 lines

  1. //--------------------------------------------------------------------
  2. // HILITEWD.AML
  3. // Highlight Word, (C) 1993-1996 by nuText Systems
  4. //
  5. // This macro highlights the word at the cursor. The user is prompted to
  6. // select a color from a color chart. Cancelling the color chart will
  7. // remove the highlighting for the word.
  8. //
  9. // This macro also calls the Clrchart macro.
  10. //
  11. // Usage:
  12. //
  13. // Select this macro from the Macro List (on the Macro menu), or run it
  14. // from the macro picklist <shift f12>.
  15. //--------------------------------------------------------------------
  16.  
  17. // compile time macros and function definitions
  18. include bootpath "define.aml"
  19.  
  20. // test for edit windows
  21. if not wintype? "edit" then
  22.   msgbox "Edit windows only!"
  23.   return
  24. end
  25.  
  26. window = getcurrwin
  27.  
  28. variable word, sobj
  29.  
  30. // called by CLRCHART.X when changing the color
  31. function oncolor (attr)
  32.   set word attr sobj
  33.   setframe '+' window
  34.   display
  35. end
  36.  
  37. // get the syntax object to use
  38. sobj = onsyntax (getbufname)
  39. if not sobj then
  40.   if object? "xword" then
  41.     sobj = "xword"
  42.   else
  43.     return
  44.   end
  45. end
  46.  
  47. // get the word at the cursor
  48. word = getword "a-zA-Z_0-9?"
  49. if not word then
  50.   display
  51.   say "No word at the cursor"
  52.   return
  53. end
  54.  
  55. // turn syntax highlighting On
  56. setting 'X' ON sobj
  57.  
  58. // call Clrchart to change the color
  59. value = runmacro (bootpath "macro\\clrchart.x") ''
  60.                  '' '' (getpalette 8) (getcurrobj)
  61.  
  62. // remove highlight if Clrchart is cancelled
  63. if value == -1 then
  64.   destroyvar word sobj
  65.   setframe '+' window
  66. end
  67.  
  68. display
  69.